<template>
	<view class="container" @click="getShowMoreId($event)">
		<view style="height: 40rpx; position: fixed; background-color: #FFFFFF;" v-if="isFullScreen"></view>
		<view class="myheader">
			<view class="redD" v-if="redDot"></view>
			<image style="z-index: 99999;" src="https://images.linglinggong.net/icon1/msg.png" mode="aspectFill"
				@click="getMessage"></image>
			<text>任务中心</text>
		</view>
		<!-- 顶部tab -->
		<view class="tab-bar">
			<view :class="selectTab === 0 ? 'select' : ''" @click="handleTabChange({ detail: { current: 0 } })">全部
			</view>
			<view :class="selectTab === 1 ? 'select' : ''" @click="handleTabChange({ detail: { current: 1 } })"> 招募中
				<view class="redDreceive" v-if="isReceiveBarRed"></view>
			</view>
			<view :class="selectTab === 2 ? 'select' : ''" @click="handleTabChange({ detail: { current: 2 } })"> 待结算
				<view class="redDreceive" v-if="isknockoffBarRed"></view>
			</view>
			<view :class="selectTab === 3 ? 'select' : ''" @click="handleTabChange({ detail: { current: 3 } })">已驳回
			</view>
			<view :class="selectTab === 4 ? 'select' : ''" @click="handleTabChange({ detail: { current: 4 } })">已完成
			</view>
		</view>
		<!-- 主体内容 -->
		<view class="list">
			<view style="width: 100%;display: flex;justify-content: center;align-items: center;margin-bottom: 15rpx;"
				v-if="seedingArr.length>0">
				<my-swiper :list="seedingArr"></my-swiper>
			</view>
			<scroll-view scroll-y="true">
				<!-- 工作信息 -->
				<view class="job-info" v-for="item in jobList" :key="item.id"
					@click="handleOpenPage(item.id, item.status)">
					<view>
						<view>
							<view
								style="width: 10rpx; height: 40rpx; background: #FCC928; margin-top: 3rpx; border-radius: 0 5rpx 5rpx 0;">
							</view>
							<text>{{ item.name.length > 9 ? item.name.slice(0, 9) + '...' : item.name }}</text>
						</view>
						<!-- 状态栏 -->
						<view class="status" :class="
							item.status === 1
								? 'waitPayGold'
								: item.vipFlag === 1 && item.status === 3
								? 'vipPutOn'
								: item.status === 3
								? 'putOn'
								: item.status === 4
								? 'putDown'
								: item.status === 5
								? 'finish'
								: item.status === 6
								? 'cancel'
								: item.status === 7
								? 'waitPay'
								: item.checkStatus === 2
								? 'reject'
								: 'examine'
						">
							<text>
								{{ item.status === 1 && item.serverFlag
									? '待付款'
									: item.status === 1
									? '待付款'
									: item.status === 3
									? '招募中'
									: item.status === 4
									? '工作中'
									: item.status === 5
									? '已完成'
									: item.status === 6
									? '已取消'
									: item.status === 7
									? '待结算'
									: item.checkStatus === 2
									? '已驳回'
									: '审核中'
							}}
							</text>
						</view>
					</view>
					<view class="job-info-content">
						<view>
							<text>{{ item.reward }}</text>
							<text>
								金额（{{ item.taskType == 0 ? '元/小时' : item.taskType == 1 ? '元/件' : item.taskType == 2 ? '元/天' : '' }}）
								<!-- <text class="floorsstr-view" v-if="item.floorsstr == 1">保底</text> -->
							</text>
						</view>
						<view>
							<text>{{ item.number }}</text>
							<text>雇员数（人）</text>
						</view>
						<view>
							<text class="text-color">{{ item.readNum }}</text>
							<text>查看人数</text>
						</view>
					</view>
					<!-- 原来的内容 -->
					<!-- view>
					<view>
						<text>{{ item.reward }}</text>
						<text>
							金额（{{ item.taskType == 0 ? '元/小时' : item.taskType == 1 ? '元/件' : item.taskType == 2 ? '元/天' : '' }}）
							<text class="floorsstr-view" v-if="item.floorsstr == 1">保底</text>
						</text>
					</view>
					<view style="width: 1rpx;height: 80rpx;border-left: 1rpx solid #F5F5F5; margin-right: 1rpx;"></view>
					<view>
						<text>{{ item.number }}</text>
						<text>雇员数（人）</text>
					</view>
					<view style="width: 1rpx;height: 80rpx;border-left: 1rpx solid #F5F5F5; margin-right: 1rpx;"></view>
					<view>
						<text>100</text>
						<text>查看人数</text>
					</view>
				</view> -->
					<!-- <view>
					<image src="/static/icon1/shijian.png"></image>
					<text>{{ getShowAdd(item.address) }}</text>
				</view> -->
					<view>
						<image src="https://images.linglinggong.net/FvhMGTnpD1KH-HUkBUnxJar8SQn5"></image>
						<view class="time">
							<text>{{item.startTime.substring(5,10)+' '}}</text>
							<text class="time-color">{{item.startTime.substring(11,16)+' '}}</text>
							<text>至</text>
							<text>{{' '+item.endTime.substring(5,10)}}</text>
							<text class="time-color">{{' '+item.endTime.substring(11,16)}}</text>
						</view>
					</view>
					<!-- 
				<view class="money">
					{{ item.reward }}{{ item.taskType==0 ? '元/小时' : item.taskType==1 ? '元/件' : item.taskType==2 ? '元/天' : ''}}
				</view>
				<view style="display: none;" class="money" v-if="item.taskType==1">{{ item.floorsAmount }}元/小时</view>
 -->
					<view class="status-info" v-if="item.status == 3 || item.status == 4" :style="{
						'margin-bottom': item.status == 3 || item.status == 4 || item.checkStatus == 2 || (item.remark != '审核通过'||item.remark != '自动审核通过' && item.remark != '') ? '36rpx' : '16rpx'
					}">
						<image
							v-if="(item.status == 3 || item.status == 4) && item.remark == '审核通过' ||item.remark == '自动审核通过'"
							src="https://images.linglinggong.net/FgEUlaZ6zg0rlWU2S47Cn_5bq1qJ" mode="widthFix"></image>
						<text>
							{{ (item.status == 3 || item.status == 4) && item.remark == '审核通过'||item.remark == '自动审核通过'
								? item.applyNum == 0
									? '暂无雇员接单&#12288;&#12288;&#12288;'
									: '有' + item.applyNum + '个雇员接单&#12288;&#12288;&#12288;'
								: ''
						}}
						</text>
						<image
							v-if="item.checkStatus == 2 || (item.remark != '审核通过' && item.remark != '自动审核通过' && item.remark != '')"
							src="https://images.linglinggong.net/Fu0_PmwZ3ZA7mYZGFdaxTEV6XIMm" mode="aspectFill">
						</image>
						{{ item.checkStatus == 2 && (item.remark != '审核通过'||item.remark != '自动审核通过') && item.remark != '' ? '驳回理由: ' + item.remark : '' }}
						{{ item.status == 4 && (item.remark != '审核通过'&& item.remark != '自动审核通过') && item.remark != '' ? '下架理由: ' + item.remark : '' }}
					</view>
					<view class="status-info" style="margin-bottom: 30rpx;" v-if="item.status == 3 || item.status == 4">
						<image style="width: 32rpx;height: 32rpx;"
							v-if="(item.status == 3 || item.status == 4) && item.remark == '审核通过' ||item.remark == '自动审核通过'"
							src="http://images.linglinggong.net/FvnfgrEGuvb4ybqHD-mf5K4bQ-5x"></image>
						<text>{{item.applyUserNum}}人联系过</text>
					</view>
					<view class="last-line" v-if="!(item.status == 2 && item.checkStatus == 1)">
						<!-- <view class="last-line-more" v-show="item.status !=7  && item.status != 4">
						<text @click.stop="isShowMoreId=isShowMoreId==item.id?-1:item.id">更多</text>
						<view class="last-line-more-view">
							<view v-if="isShowMoreId==item.id" class="last-line-more-view-pop">
								<view class="last-line-more-view-pop-list" @click.stop="handleOpenModal(0, item.status, item.id, item)">
									{{ (item.status == 6 || item.status == 5 ) ? '删除' : '取消' }}
								</view>
								<view class="last-line-more-view-pop-list" @click.stop="handleOpenModal(2+item.takehide, item.status, item.id)" v-show="item.status === 3">
									{{ item.takehide==0 ? '隐藏' : '显示'}}
								</view>
							</view>
						</view>
					</view> -->
						<view class="buttons" v-if="item.status !=7  && item.status != 4">
							<view class="button zhifu button-style"
								@click.stop="handleOpenModal(0, item.status, item.id, item)">
								{{ (item.status == 6 || item.status == 5 ) ? '删除' : '取消' }}
							</view>
							<view class="button zhifu button-style"
								@click.stop="handleOpenModal(2+item.takehide, item.status, item.id)"
								v-if="item.status == 3 && item.applyNum>0">
								{{ item.takehide==0 ? '隐藏' : '显示'}}
							</view>
							<view class="button zhifu button-style"
								@click.stop="markUp(item.id, item.status,item.reward,item.taskType,item.startTime,item.endTime)"
								v-if="item.applyNum == 0 && item.status == 3"> 加价 </view>
							<view class="button zhifu" @click.stop="again(item.id)" v-if="item.status == 6"> 再来一单
							</view>
						</view>
						<!-- 文字说明 -->
						<!-- <view class="status-info">
					    {{ item.status == 3 || item.status == 4 ? ('有'+ item.applyNum + '个雇员接单&#12288;&#12288;&#12288;') :''}}
						{{ item.checkStatus ==2 ||  item.remark !="审核通过" && item.remark !="" ? ('原因: '+ item.remark) :''}}
						{{ item.checkStatus ==2 ||  item.remark !="审核通过" && item.remark !="" ? ('下架理由: '+ item.remark) :''}}
					</view> -->
						<!-- 按钮 -->
						<view class="buttons">
							<!-- {{item.status}} -->
							<!-- <view @click.stop="handleOpenModal(0, item.status, item.id)" class="button" v-if="item.status !=7 && item.status !=4">
							{{ (item.status == 6 || item.status == 5 ) ? '删除' : '取消' }}
						</view> -->
							<!-- <view @click.stop="handleOpenModal(0, item.status, item.id, item)" class="button quxiao"
							v-show="item.status !=7  && item.status != 4">
							{{ (item.status == 6 || item.status == 5 ) ? '删除' : '取消' }}
						</view> -->
							<!-- <view @click.stop="handleOpenModal(2+item.takehide, item.status, item.id)" class="button"
							:class="item.takehide==0 ? 'yincang' : 'zhifu'" v-show="item.status === 3">
							{{ item.takehide==0 ? '隐藏' : '显示'}}
						</view> -->
							<!-- <view
							v-if="item.status === 3 || item.applyNum == 0"
							class="bottom-button-view-alert"
							:style="{ left: item.number - item.applyNum > 0 && item.invitation < item.number ? '33.5%' : '65%' }">
							<view class="bottom-button-view-alert-view">分享别人来接单吧！</view>
							<view class="bottom-button-view-alert-sj"></view>
						</view> -->
							<!-- <view @click.stop="(isOpenModal = true), (fenXiangId = item.id), getTitle(item)" class="button zhifu" v-show="item.status === 3 || item.applyNum == 0">分享</view> -->
							<view @click.stop="handleOpenModal(4, item.status, item.id, item)"
								v-if="item.status === 3 && item.number - item.applyNum > 0 && item.invitation < item.number"
								class="button zhifu">
								{{ '邀请' }}
								<text class="old-employee">老雇员</text>
							</view>
							<view @click.stop="handleOpenModal(1, item.status, item.id)"
								v-if="(item.status == 1 || item.status == 5 || item.checkStatus == 2) && item.status != 6"
								class="button zhifu">
								{{ item.status == 1 ? '支付' : item.checkStatus == 2 ? '重新发布' : item.status == 5 ? '一键发布' : '一键发布' }}
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<!-- 空列表logo -->
		<view class="nullListLogo" v-if="isShowNullList">
			<image src="https://images.linglinggong.net/icon1/dingdan.png" mode="aspectFill"></image>
			<text>这里没有相关的任务</text>
		</view>
		<!-- 加载 -->
		<uni-load-more :status="hasFlag ? 'loading' : 'noMore'" v-if="!isShowNullList"></uni-load-more>
		<view class="hg-108" style="background-color: #F2F2F2;"></view>
		<!-- 弹窗 -->
		<modal :titleColor="titleColor" :contentColor="contentColor" :contentsColor="contentsColor"
			:isShowModal="isShowModal" :modalStytle="modalStytle" :unitPrice="unitPrice" :workTime="workTime"
			:workPrice="workPrice" :button="button" :status="clickStatus" :clickJobType="clickJobType"
			@handleLeft="handleLeft" @handleRight="handleRight" :titleContect="titleContect"
			:middleContext="middleContext" :leftContext="leftContext" :rightContext="rightContext"></modal>
		<!-- 引导对话框 -->
		<view class="nullListMsg" v-if="isShowNullList && isShowfabu">
			<view>点击这里发布任务</view>
			<view></view>
		</view>
		<!-- <view class="hg-98"></view> -->
		<jobPay v-if="isShowPay" :get-task-id="newTaskId" @closePayPage="isShowPay = false"></jobPay>
		<hans-tabber :indexNum="0" style="position:fixed;bottom:0;width:100%;left:0;right:0;"></hans-tabber>
		<!-- 分享弹框 -->
		<view class="share-modal" v-show="isOpenModal">
			<view class="main">
				<image @click="handleCloseModal" class="close" src="https://images.linglinggong.net/icon3/gb.png">
				</image>
				<view>
					<view @click="handleShare('WXSenceTimeline')">
						<image src="https://images.linglinggong.net/icon3/000000001.png" mode="aspectFill"></image>
						<text>朋友圈</text>
					</view>
					<view @click="handleShare('WXSceneSession')">
						<image src="https://images.linglinggong.net/icon3/0000000002.png" mode="aspectFill"></image>
						<text>微信群</text>
					</view>
					<view @click="handleShare('WXSceneSession')">
						<image src="https://images.linglinggong.net/icon3/00000000003.png" mode="aspectFill"></image>
						<text>喊工友</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import hansTabber from '@/components/hans-tabbar/hans-tabbar.vue';
	import jobPay from './send-job-pay/send-job-pay-new.vue'
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import modal from '@/components/modal/modal.vue';
	import mySwiper from '@/components/beckhayu-swiper/my-swiper.vue'
	import {
		getContacts
	} from '@/libs/unit.js'
	import {
		debounce
	} from "@/untils/debounce_throttle.js"
	export default {
		components: {
			uniLoadMore,
			modal,
			hansTabber,
			jobPay,
			mySwiper,
		},
		data() {
			return {
				titleColor: '#402110',
				contentColor: '#402110',
				contentsColor: '#fe4b28',
				modalStytle: 3, //0-left-text,1-two-line,2-hasInput, 3-middle-context
				hasFlag: true, //是否加载完成
				timer: null, //定时器
				selectTab: 0, // 当前选中的tabbar索引 index
				button: 1, //按钮类型
				taskId: '', //点中的工作taskId
				clickStatus: 0, //工作状态
				clickJobType: 2, //工作类型0计时工，1：计天工，2计件工
				isShowModal: false, //是否显示弹框
				titleContect: '', //弹框标题
				middleContext: '', //弹框中间的内容
				unitPrice: 0, //计件单价
				workTime: '0', //计时工作时间
				workPrice: 0, //工作单价
				leftContext: '取消', //弹框按钮左边的内容
				rightContext: '确认', //弹框按钮右边的内容
				jobList: [],
				requestObj: {
					pageNum: 0,
					pageSize: 10,
					userId: '',
					status: '',
					userId: '',
					isAsc: 'desc',
					orderByColumn: 'createTime'
				},
				userInfo: {
					user: {},
					params: {}
				}, //当前用户信息
				imgPath: '', //图片路径
				street: {}, //街道
				handleIsStop: true, // 是否允许切换
				isShowNullList: false, //是否是空零工
				isShowfabu: false, //是否显示发布
				isTabBarRed: false,
				isFullScreen: false, //是否是全面屏
				isShowPay: false, //是否显示付款窗口
				newTaskId: '', //发布任务的id
				isReceiveBarRed: false,
				isknockoffBarRed: false,
				isOpenModal: false,
				fenXiangId: 0,
				wechatTitle: '我在找零工接单了',
				wechatInfo: '海量高薪任务日结，工作轻松，时间自由，上班不如一起做零工！',
				isShowMoreId: -1,
				bannerList: ['https://images.linglinggong.net/static/x-luobo1.png',
					'https://images.linglinggong.net/static/x-luobo2.png'
				],
				seedingArr: [],
				scrollTop: 0,
				localStroage: 'boosMyJobNew', // 存储的名称
				redDot: false, //消息红点
			};
		},
		methods: {
			async get_lately_task_name() {
				let res = await this.$fetch(this.$api.get_lately_task_name_v2, {
					pageSize: 18,
					position: 'BUSINESS_TASK_LIST'
				}, 'POST')
				this.seedingArr = res.data.banner
			},
			updateUserImage(e) {},
			//判断是否是 刘海 全面屏
			setFullScreen() {
				if (plus.navigator.hasNotchInScreen()) {
					this.isFullScreen = true;
				} else {
					this.isFullScreen = false;
				}
			},
			//加价
			markUp(id, taskStatus, reward, taskType, startTime, endTime) {
				uni.navigateTo({
					url: `/pages/mark-up/mark-up?id=${id}&taskStatus=${taskStatus}&reward=${reward}&taskType=${taskType}&startTime=${startTime}&endTime=${endTime}`
				});
			},
			//打开消息
			getMessage() {
				uni.navigateTo({
					url: '/pages/message/message-new'
				});
			},
			getShowAdd(add) {
				add = add.split('·');
				add.pop();
				return add.join('·');
			},
			//打开弹框
			handleOpenModal(button, status, taskId, item) {
				this.taskId = taskId;
				// console.log('button',button, 'status',status,'id', taskId)
				this.button = button;
				this.clickStatus = status;
				if (button === 0 && (status == 6 || status == 5 || status == 4)) {
					this.modalStytle = 99;
					this.titleContect = '删除任务';
					this.middleContext = ' 是否删除任务？';
					this.leftContext = '取消';
					this.rightContext = '确认';
					this.isShowModal = true;
					this.titleColor = '#402110';
					this.contentColor = '#402110';
				} else if (button === 0 && status != 6 && status != 5) {
					this.titleColor = '#000000';
					this.contentColor = '#787878';
					this.modalStytle = 99;
					this.titleContect = '取消任务';
					if (item.applyNum == 0) {
						this.middleContext = '确认要取消任务吗？';
					} else {
						this.modalStytle = 98;
						this.contentsColor = '#fe4b28';
						let g = item.sincerityGold / 100;
						g = g / item.number;
						g = g * item.applyNum;
						let middleContext = item.userpaytype == 1 ? '任务已被接单，取消将会#扣除' + g + '元诚意金#作为违约补贴，你确认要取消吗？' : item
							.userpaytype == 2 ? '任务已被接单，取消将会#扣除' + g + '元服务费#作为违约补贴，你确认要取消吗？' : item.userpaytype == 3 ?
							'任务已被接单，取消将会#消耗直通卡' + item.applyNum + '人#，你确认要取消吗？' : '任务已被接单，取消将会#扣除' + g +
							'元诚意金#作为违约补贴，你确认要取消吗？';
						this.middleContext = middleContext;
					}
					this.leftContext = '取消';
					this.rightContext = '确认';
					this.isShowModal = true;
				} else if (button == 2 && status == 3) {
					this.titleColor = '#000000';
					this.contentColor = '#787878';
					this.modalStytle = 99;
					this.titleContect = '隐藏任务';
					this.middleContext = '是否对雇员们隐藏您的任务!';
					this.leftContext = '取消';
					this.rightContext = '确认';
					this.isShowModal = true;
				} else if (button == 3 && status == 3) {
					this.titleColor = '#000000';
					this.contentColor = '#787878';
					this.modalStytle = 99;
					this.titleContect = '显示任务';
					this.middleContext = '是否对雇员们显示您的任务!';
					this.leftContext = '取消';
					this.rightContext = '确认';
					this.isShowModal = true;
				} else if (button == 4 && status == 3) {
					// 雇佣
					if (item.number - item.applyNum < 1) {
						uni.showToast({
							title: '人数已经满,不用再邀请了~',
							icon: 'none'
						});
					} else {
						uni.navigateTo({
							url: '/pages/app-employer/my-employee/my-employee-new?taskId=' + item.id + '&num=' + (
								item.number - item.applyNum)
						});
					}
				} else if (button == 1 && status == 1) {
					// 支付
					this.newTaskId = this.taskId;
					// this.isShowPay = true
					// uni.navigateTo({
					// 	url: '/pages/app-employer/send-job-pay/send-job-pay?taskId=' + this.taskId
					// })
					uni.navigateTo({
						url: '/pages/app-employer/fabu-pay/fabu-pay?taskId=' + this.taskId
					});
				} else if (button == 1 && status == 5) {
					// 重新发单
					// 需要选择今天工作人员继续参与
					// uni.navigateTo({
					// 	url: '/pages/app-employer/send-job/send-job?taskId=' + this.taskId + '&type=new'
					// })
					uni.navigateTo({
						url: '/pages/quickSendJob/quickSendJob?taskId=' + this.taskId + '&timeFlag=' + 0 +
							'&people=' + 1 + '&page=' + 1
					});
				} else if (this.button == 1 && this.clickStatus == 2) {
					// 驳回修改
					// 人数不能变
					uni.navigateTo({
						url: '/pages/app-employer/send-job/send-job?taskId=' + this.taskId + '&type=bohui'
					});
				}
			},
			//再来一单
			again(e) {
				uni.navigateTo({
					url: '/pages/app-employer/send-job/send-job?taskId=' + e + '&type=new'
				})
			},
			//弹框左键
			handleLeft() {
				this.isShowModal = false;
			},
			//计算任务人数，报名加邀请的人数
			addTaskNumber(number, invitation) {
				let v = parseInt(number) + parseInt(invitation);
				return v;
			},
			//弹框右键
			async handleRight() {
				this.isShowModal = false;
				// 删除
				if (this.button == 0 && (this.clickStatus == 6 || this.clickStatus == 5 || this.clickStatus == 4)) {
					let res = await this.$fetch(this.$api.del_task, {
						taskId: this.taskId
					}, 'POST');
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					// 取消
				} else if (this.button == 0 && this.clickStatus != 6 && this.clickStatus != 5) {
					let res = await this.$fetch(this.$api.cancel_task, {
						taskId: this.taskId
					}, 'POST');
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					});
				} else if (this.button == 2 && this.clickStatus == 3) {
					let res = await this.$fetch(this.$api.hide_task, {
						taskId: this.taskId,
						token: uni.getStorageSync('token'),
						hide: 1
					}, 'POST');
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					});
				} else if (this.button == 3 && this.clickStatus == 3) {
					let res = await this.$fetch(this.$api.hide_task, {
						taskId: this.taskId,
						token: uni.getStorageSync('token'),
						hide: 0
					}, 'POST');
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					});
				}
				this.refresh();
			},
			// 更改类目
			handleTabChange({
				detail: {
					current
				}
			}) {
				if (this.selectTab == current) return;
				// 只有切换成功的时候才给他清空，这样做是为了在切换的时候不会出现刚进去就到达指定位置
				uni.setStorageSync('scrollTop', 0);
				this.selectTab = current;
				if (this.selectTab == 1) {
					uni.setStorageSync('isReceiveBarRed', false);
					this.isReceiveBarRed = false;
				}
				if (this.selectTab == 2) {
					uni.setStorageSync('isknockoffBarRed', false);
					this.isknockoffBarRed = false;
				}
				this.requestObj.status = this.selectTab == 0 ? '' : this.selectTab == 1 ? 3 : this.selectTab == 3 ? 8 :
					this.selectTab == 4 ? 5 : '';
				this.requestObj.statusIn = this.selectTab == 2 ? '4,7' : '';
				this.refresh();
			},
			//打开订单详情页
			handleOpenPage(id, taskStatus) {
				uni.navigateTo({
					url: '/pages/app-employer/boss-order-detail/boss-order-detail?id=' + id + '&taskStatus=' +
						taskStatus
				});
			},
			//待开工招人提醒
			standTask(id, time) {
				let info = {
					taskId: id,
					taskTime: time
				};
				uni.setStorageSync('taskDKGTX', info);
			},
			//获取我的零工
			async task_list() {
				// console.log('获取我的零工', this.hasFlag, this.handleIsStop);
				if (!this.hasFlag) return; // 说明已经没有更多啦
				++this.requestObj.pageNum;
				if (!this.handleIsStop) return uni.showToast({
					title: '你点击得太快啦~',
					icon: 'none'
				}); // 说明上一条请求结果未返回
				this.handleIsStop = false;
				this.requestObj.userId = this.userInfo.userId;
				console.log('获取task_list提交参数：', this.requestObj.status)
				let res = await this.$fetch(this.$api.task_list, this.requestObj, 'POST');
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				});
				if (res.rows.length == 0) {
					this.isShowNullList = true;
				} else {
					this.isShowNullList = false;
				}
				if (res.rows.length == 0 && this.selectTab == 0) {
					this.isShowfabu = true;
				}
				console.log('获取我发布的零工 res.rows[0]', res.rows[0]);
				res.rows.forEach(item => {
					item.reward = item.reward.divide(100);
					item.floorsAmount = item.floorsAmount ? item.floorsAmount.divide(100) : 0;
					// console.log('获取我的零工 item',item)
					//待开工提醒
					// if(item.status == 3){
					// 	this.standTask(item.id,item.startTime)
					// }
				});
				uni.stopPullDownRefresh();
				this.handleIsStop = true;
				this.jobList = [...this.jobList, ...res.rows];
				// console.log('666', this.jobList)
				this.hasFlag = this.requestObj.pageSize * this.requestObj.pageNum < res.total;
			},
			// 刷新
			refresh() {
				this.jobList = [];
				this.hasFlag = true;
				this.requestObj.pageNum = 0;
				this.requestObj.pageSize = 10;
				uni.setStorageSync(this.localStroage, 0);
				if (this.selectTab == 2) {
					// 获取待结算列表2022年10月
					this.requestObj.status = 2
				}
				this.task_list();
			},
			//邀请成功
			inviteSucceed() {
				setTimeout(() => {
					uni.showToast({
						title: '邀请成功~',
						icon: 'none'
					});
				}, 1000);
			},
			// 关闭分享弹框
			handleCloseModal() {
				this.isOpenModal = false;
			},
			//分享
			handleShare(scene) {
				console.log('分享场景', scene);
				this.task_share();
				uni.share({
					provider: 'weixin',
					scene: scene,
					type: 0,
					href: 'http://share.linglinggong.net/#/?taskId=' + this.fenXiangId + '&fenxid=' + uni
						.getStorageSync('userId'),
					// title: "我在找零工接单了",
					title: this.wechatTitle,
					summary: this.wechatInfo,
					imageUrl: 'https://images.linglinggong.net/FovByz9oRrP4wIPyrtiJJf-0cxwB',
					success: function(res) {
						// console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log('fail:' + JSON.stringify(err));
						uni.showToast({
							title: '未登陆',
							icon: 'none'
						});
					}
				});
			},
			async task_share() {
				let res = await this.$fetch(this.$api.task_share, {
					type: 1
				}, 'POST');
			},
			getTitle(item) {
				this.wechatTitle = item.address.split('·').splice(0, 2).join('·') + '|' + item.name + '|' + item.reward + (
					item.taskType == 0 ? '元/小时' : item.taskType == 1 ? '元/件' : '元/天');
				this.wechatInfo = item.taskContent == '' ? '海量高薪任务日结，工作轻松，时间自由，上班不如一起做零工！' : item.taskContent;
				console.log(this.wechatInfo);
			},
			getShowMoreId(e) {
				this.isShowMoreId = -1
			},
			//消息红点
			async get_push_message_records_red_dot() {
				let res = await this.$fetch(this.$api.get_push_message_records_red_dot, {}, 'GET')
				if (res.code) uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.redDot = res.data
			},
			// 优化滚动条触发次数
			optimizeScroll: debounce(100, function(e) {
				// console.log('执行的滚动条optimizeScroll', e);
				// 判断滚动条的位置，如果有的话就执行，没有就不执行
				this.scrollFn(e);
			}),
			// 滚动条滚动
			scrollFn(scroll) {
				// console.log('滚动条滚动scrollFn', scroll);
				// 记录滚动位置，从详情页返回的时候会继续展示刚才的位置
				uni.pageScrollTo({
					scrollTop: scroll,
					duration: 100
				})
			}
		},
		onLoad() {
			this.get_lately_task_name()
			// #ifdef APP-PLUS
			if (uni.getStorageSync('token')) {
				setTimeout(() => {
					getContacts()
				}, 1000)
			}
			this.setFullScreen();
			// #endif
			this.userInfo = uni.getStorageSync('userInfo');
			this.imgPath = uni.getStorageSync('imgPath');
			this.street = uni.getStorageSync('street');
			// uni.startPullDownRefresh()
			//判断是否是 刘海 全面屏
		},
		onShow() {
			// 获取到本地存储的滚动条位置
			const scrollTop = uni.getStorageSync(this.localStroage);
			// 判断是否存在 如果存在就会执行 或者 == 0 也会执行(0 = false)
			if (scrollTop || scrollTop == 0) {
				this.scrollFn(scrollTop)
			}
			this.task_list();
			// this.refresh();
			if (this.timer == null) {
				clearInterval(this.timer);
			}
			console.log('我发布的零工');
			this.timer = setInterval(() => {
				this.isReceiveBarRed = uni.getStorageSync('isReceiveBarRed');
				this.isTabBarRed = uni.getStorageSync('isTabBarRed');
				this.isknockoffBarRed = uni.getStorageSync('isknockoffBarRed');
			}, 1000);
			this.get_push_message_records_red_dot()
		},
		onReachBottom() {
			this.task_list();
		},
		onBackPress() {
			if (this.isShowPay) {
				return true;
			}
		},
		onPullDownRefresh() {
			//监听用户下拉动作，一般用于下拉刷新
			this.refresh();
		},
		onHide() {
			clearInterval(this.timer);
			// 判断滚动条的位置，如果有的话就执行，没有就不执行
			uni.setStorageSync(this.localStroage, this.scrollTop);
		},
		onPageScroll(e) {
			// console.log('执行了你onPageScroll');
			this.scrollTop = e.scrollTop;
			this.optimizeScroll(this.scrollTop);
		},
		onShareAppMessage() {
			return {
				title: "足不出户，免费招工",
				desc: "线上招募零工，工价透明，免费使用",
				path: `/pages/start-n/start-n`,
				imageUrl: 'https://images.linglinggong.net/static/employer-share.jpg',
				success: res => {}
			}
		},
	};
</script>
<style lang="less" scoped>
	@mt : calc((var(--status-bar-height))/2);

	.container {
		overflow: hidden;

		.myheader {
			z-index: 1;
			position: fixed;
			display: flex;
			background-color: #ffffff;
			font-size: 32rpx;
			font-weight: bold;
			color: #000000;
			height: 120rpx;
			text-align: center;
			align-items: center;
			width: 100%;
			padding-top: calc(20rpx + @mt);

			&>text {
				flex: 1;
				margin-left: -110rpx;
			}

			&>image {
				// margin-right: 38rpx;
				margin-left: 38rpx;
				margin-bottom: 2rpx;
				height: 50rpx;
				width: 50rpx;
			}
		}

		&>.tab-bar {
			z-index: 1;
			position: fixed;
			display: flex;
			height: 90rpx;
			margin-top: calc(110rpx + @mt);
			background-color: #ffffff;
			font-size: 26rpx;
			box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.03);

			&>view {
				// border: 1px solid #007AFF;
				display: flex;
				width: 20vw;
				height: 90rpx;
				// position: relative;
				justify-content: center;
				align-items: center;
				color: rgba(64, 33, 16, 0.5);
			}

			&>.select {
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
				font-size: 32rpx;
				font-weight: bold;
				color: #402110;

				&::before {
					content: '';
					position: absolute;
					left: 65.75rpx;
					bottom: 0;
					width: 56rpx;
					height: 6rpx;
					background: #fcc928;
					border-radius: 3rpx;
				}
			}
		}

		&>.list {
			margin-top: calc(220rpx + (var(--status-bar-height)) / 2);
			margin-left: 30rpx;
			margin-right: 30rpx;

			.job-info {
				margin-bottom: 20rpx;
				// width: 630rpx;
				//height: 400rpx;
				border-radius: 12rpx;
				position: relative;
				display: flex;
				flex-direction: column;
				background-color: #ffffff;
				padding: 36rpx 30rpx 40rpx 30rpx;

				&>view {
					display: flex;
				}

				&>view:nth-child(1) {
					justify-content: space-between;
					margin-bottom: 36rpx;

					&>view {
						display: flex;

						&>text:nth-child(2) {
							margin-left: 20rpx;
							color: #3e220a;
							line-height: 40rpx;
							font-weight: bold;
							font-size: 36rpx;
							letter-spacing: 0;
							align-items: center;
						}
					}

					&>.status {
						font-size: 24rpx;
						width: 90rpx;
						height: 36rpx;
						border-radius: 8rpx;
						color: #F39B19;

						&.putDown,
						// &.putOn,
						&.inProgress,
						&.waitPay,
						&.vipPutOn {
							color: #17c295;
							background: #effaf7;
						}

						&.examine,
						&.waitPayGold {
							color: #f37878;
							background: #fde4e4;
						}

						&.finish,
						&.reject,
						&.cancel {
							color: #aaaaaa;
							background: #f5f5f5;
						}

						&>text {
							margin: auto;
						}
					}
				}

				&-content {
					display: flex;
					justify-content: space-between;
					width: 100%;
					margin-bottom: 36rpx;

					&>view {
						display: flex;
						align-items: center;
						flex-direction: column;

						&>text:nth-child(1) {
							font-size: 48rpx;
							margin-bottom: 24rpx;
							line-height: 45rpx;
							font-weight: bold;
						}

						&>text:nth-child(2) {
							font-size: 28rpx;
							color: #a5a5a5;
						}

						.text-color {
							color: #FF650C;
						}
					}
				}

				// & > view:nth-child(2) {
				// 	display: flex;
				// 	justify-content: space-between;
				// 	width: 100%;
				// 	margin-bottom: 36rpx;
				// 	& > view:nth-child(1) {
				// 		display: flex;
				// 		align-items: center;
				// 		flex-direction: column;
				// 		transform: translateX(25%);
				// 		& > text:nth-child(1) {
				// 			font-size: 48rpx;
				// 			margin-bottom: 24rpx;
				// 			line-height: 45rpx;
				// 		}
				// 		& > text:nth-child(2) {
				// 			font-size: 24rpx;
				// 			color: #a5a5a5;
				// 		}
				// 	}
				// 	& > view:nth-child(3) {
				// 		display: flex;
				// 		align-items: center;
				// 		flex-direction: column;
				// 		transform: translateX(25%);
				// 		& > text:nth-child(1) {
				// 			font-size: 48rpx;
				// 			margin-bottom: 24rpx;
				// 			line-height: 45rpx;
				// 		}
				// 		& > text:nth-child(2) {
				// 			font-size: 24rpx;
				// 			color: #a5a5a5;
				// 		}
				// 	}
				// 	& > view:nth-last-child(1) {
				// 		display: flex;
				// 		align-items: center;
				// 		flex-direction: column;
				// 		height: 89rpx;
				// 		transform: translateX(-25%);
				// 		& > text:nth-child(1) {
				// 			font-size: 48rpx;
				// 			margin-bottom: 24rpx;
				// 			line-height: 45rpx;
				// 		}
				// 		& > text:nth-child(2) {
				// 			font-size: 24rpx;
				// 			color: #a5a5a5;
				// 		}
				// 	}
				// }
				&>view:nth-child(3) {
					// border: 1px solid #000000;
					// height: 34rpx;
					//background: #f5f5f5;
					border-radius: 8rpx;
					display: flex;
					align-items: center;
					min-height: 48rpx;
					margin-bottom: 24rpx;
					font-size: 24rpx;
					color: #000000;
					letter-spacing: 0;

					&>image {
						align-self: center;
						width: 28rpx;
						height: 28rpx;
						margin-right: 10rpx;
						margin-left: 10rpx;
					}

					&>.time {
						&>text {
							font-size: 24rpx;
							color: rgba(64, 33, 16, 0.7);
						}

						.time-color {
							color: #F39B19;
						}
					}
				}

				&>.money {
					line-height: 48rpx;
					font-weight: bold;
					font-size: 17rpx;
					color: #ff650c;
					letter-spacing: 0;
				}

				&>.status-info {
					&>image {
						align-self: center;
						width: 24rpx;
						height: 28rpx;
						margin-right: 10rpx;
						margin-left: 8rpx;
					}

					font-size: 24rpx;
					color: #a5a5a5;
				}

				&>.last-line {
					//margin-top: 30rpx;
					display: flex;
					align-items: center;
					justify-content: flex-end;
					border-top: 2rpx solid #F2F2F2;

					&>.buttons {
						margin-top: 20rpx;
						display: flex;
						align-self: flex-end;

						&>.button-style {
							border: 2rpx solid rgba(64, 33, 16, 0.5);
							background: #ffffff !important;
							color: rgba(64, 33, 16, 0.5) !important;
						}

						&>.button {
							width: 160rpx;
							height: 60rpx;
							border-radius: 36rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-size: 28rpx;

							&:active {
								opacity: 0.7;
							}
						}

						.quxiao {
							border: 1px solid #bdbdbd;
							color: #b9b9b9;
						}

						.yincang {
							border: 1px solid #bdbdbd;
							color: #b9b9b9;
							margin-left: 30rpx;
						}

						.old-employee {
							display: flex;
							align-items: center;
							justify-content: center;
							position: absolute;
							top: -16rpx;
							left: 70rpx;
							width: 92rpx;
							height: 28rpx;
							background: #FCC928;
							border-radius: 14rpx;
							font-size: 20rpx;
							color: #402110;
						}

						.zhifu {
							position: relative;
							// border: 2rpx solid #fcc928;
							background: #F39B19;
							margin-left: 30rpx;
							color: #FFFFFF;
						}
					}
				}
			}
		}

		.nullListLogo {
			//background-color: #F2F2F2;
			width: 300rpx;
			height: 316rpx;
			position: fixed;
			left: 50%;
			top: 50%;
			transform: translateX(-50%) translateY(-50%);
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-between;

			&>image {
				width: 240rpx;
				height: 240rpx;
			}

			&>text {
				color: #402110;
				font-size: 30rpx;
			}
		}
	}

	.nullListMsg {
		width: 346rpx;
		height: 105rpx;
		position: fixed;
		left: 50%;
		top: calc(100% - 140rpx);
		transform: translateX(-50%) translateY(-130%);
		text-align: center;
		z-index: 501;

		&>view:nth-child(1) {
			width: 346rpx;
			height: 90rpx;
			background: #000000;
			opacity: 0.5;
			border-radius: 10rpx;
			color: #ffffff;
			font-size: 28rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		&>view:nth-child(2) {
			width: 0;
			height: 0;
			border-left: 15rpx solid transparent;
			border-right: 15rpx solid transparent;
			border-top: 30rpx solid #000000;
			opacity: 0.5;
			position: fixed;
			left: 50%;
			transform: translateX(-50%);
		}
	}

	.redD {
		background-color: #FE4B28;
		position: relative;
		left: 84rpx;
		top: -16rpx;
		z-index: 999999999;
		width: 12rpx;
		height: 12rpx;
		border-radius: 50%;
		background-color: #F85A41;
		box-shadow: rgba(248, 90, 65, 0.50) 0 2rpx 6rpx 2rpx;
	}

	.redDreceive {
		background-color: #fe4b28;
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		bottom: 16rpx;
		position: relative;
		.anim-redD;
	}

	.anim-redD {
		animation: 2s redD 0s infinite;
	}

	@keyframes redD {
		0% {
			transform: translateY(0);
		}

		30% {
			transform: translateY(-15rpx);
		}

		40% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-10rpx);
		}

		70% {
			transform: translateY(0rpx);
		}

		80% {
			transform: translateY(-5rpx);
		}

		100% {
			transform: translateY(0);
		}
	}

	.share-modal {
		z-index: 500;
		position: fixed;
		bottom: 0;
		height: 100vh;
		width: 100vw;
		background-color: rgba(0, 0, 0, 0.4);

		&>.mains {
			position: fixed;
			bottom: 40%;
			left: 11%;
			box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.05) inset;
			border-radius: 17px 17px 0 0;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		z-index: 11;
		position: fixed;
		bottom: 0;
		height: 100vh;
		width: 100vw;
		background-color: rgba(0, 0, 0, 0.4);

		&>.mains {
			position: fixed;
			bottom: 40%;
			left: 11%;
			box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.05) inset;
			border-radius: 17px 17px 0 0;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		&>.main {
			position: fixed;
			bottom: 108rpx;
			// padding: 30rpx;
			background: #ffffff;
			box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.05) inset;
			border-radius: 17px 17px 0 0;
			z-index: 999;
			display: flex;
			flex-direction: column;

			// align-items: center;
			&>.close {
				position: absolute;
				right: 30rpx;
				top: 30rpx;
				width: 28rpx;
				height: 28rpx;
			}

			&>view {
				display: flex;
				width: 100vw;
				padding: 100rpx 0 20rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #000000;
				line-height: 45rpx;

				&>view {
					// border: 1px solid #000000;
					display: flex;
					flex: 1;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					&>image {
						width: 120rpx;
						height: 120rpx;
						margin-bottom: 24rpx;
					}
				}
			}
		}
	}

	.floorsstr-view {
		background: #fde4e4;
		border-radius: 4rpx;
		color: #e62b00;
		padding: 3rpx 8rpx;
	}

	.bottom-button-view-alert {
		width: 248rpx;
		height: 60rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: absolute;
		bottom: 120rpx;
		.anim-bounce;
	}

	.bottom-button-view-alert-view {
		width: 248rpx;
		height: 48rpx;
		background: linear-gradient(-90deg, #ff7e28, #ff231c);
		font-size: 24rpx;
		line-height: 48rpx;
		font-weight: 500;
		color: #ffffff;
		text-align: center;
		border-radius: 48rpx;
	}

	.bottom-button-view-alert-sj {
		width: 0;
		height: 0;
		border-left: 10rpx solid transparent;
		border-right: 10rpx solid transparent;
		border-top: 20rpx solid #ff231c;
	}

	.anim-bounce {
		animation: 2.5s bounce 0s infinite;
	}

	@keyframes bounce {
		0% {
			transform: scale(1, 1);
		}

		50% {
			transform: scale(0.8, 0.8);
		}

		100% {
			transform: scale(1, 1);
		}
	}

	.last-line-more {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #7f7f7f;
		line-height: 68rpx;
		width: 100%;
	}

	.last-line-more-view {
		width: 167rpx;
		// height: 167rpx;
		position: absolute;
		left: 0;
		z-index: 1;

		.last-line-more-view-pop {
			width: 167rpx;
			// height: 151rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
			border-radius: 12rpx;
			margin-top: 16rpx;
		}

		.last-line-more-view-pop::before {
			position: absolute;
			display: inline-block;
			top: 0rpx;
			left: 40rpx;
			width: 0;
			height: 0px;
			content: '';
			border-style: solid;
			border-width: 16rpx;
			border-color: #fff #fff transparent transparent;
			background-color: #fff;
			transform: rotate(135deg);
			box-shadow: -2rpx 1rpx 4rpx -1rpx rgba(0, 0, 0, 0.1);
		}
	}

	.last-line-more-view-pop-list {
		padding: 20rpx 0 20rpx 36rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #7F7F7F;
		line-height: 24rpx;
	}
</style>